/**
 * @author 黄波
 * 创建日期：2011Oct 3, 2011
 * TODO// N/A
 */
package com.platform.course.action;

import java.io.PrintWriter;
import java.util.HashMap;

import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;

import com.platform.constant.ResponseCode;
import com.platform.course.bo.CourseBo;
import com.platform.pojo.CourseDirectory;
import com.platform.res.bo.ResBo;

/**
 * 添加课程目录
 */
public class AddCourseDirAction extends CourseSupport {

	private CourseDirectory item;
	private boolean success;
	private String msg;
	
	@Override
	public String execute() throws Exception {
		CourseBo bo = CourseBo.getInstance();
		if(bo.addCourseDirectory(item)) {
			msg = ResponseCode.SUCCESS_ADD;
		} else {
			msg = ResponseCode.FAILURE_ADD;
		}
		success = true;
		HashMap map = new HashMap();
		map.put("msg", msg);
		map.put("success", success);
		JSONObject json = JSONObject.fromObject(map);
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
		out.println(json);
		out.flush();
		out.close();
		return null;
	}
	public CourseDirectory getItem() {
		return item;
	}
	public void setItem(CourseDirectory item) {
		this.item = item;
	}
	public boolean isSuccess() {
		return success;
	}
	public void setSuccess(boolean success) {
		this.success = success;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	
}
